package com.itheima.sc.service.sms;

import cn.hutool.core.convert.Convert;
import com.itheima.sc.api.sms.SmsHomeRecommendSubjectApi;
import com.itheima.sc.pojo.sms.HomeRecommendSubject;
import com.itheima.sc.vo.PageResult;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class SmsHomeRecommendSubjectService {

    @DubboReference
    private SmsHomeRecommendSubjectApi recommendSubjectApi;

    //添加首页推荐
    public void addRecommendSubjects(List<HomeRecommendSubject> recommendSubjects) {
        recommendSubjectApi.addRecommendSubjects(recommendSubjects);
    }

    //批量删除
    public void deleteRecommendSubjects(List<Long> ids) {
         recommendSubjectApi.deleteRecommendSubjects(ids);
    }

    //分页查询首页推荐
    public PageResult selectRecommendSubjectList(Map<String, String> param) {
        String SubjectName = param.get("SubjectName");
        Integer page = Convert.toInt(param.get("pageNum"));
        Integer pageSize = Convert.toInt(param.get("pageSize"));
        Integer recommendStatus = Convert.toInt(param.get("recommendStatus"));
        return recommendSubjectApi.selectRecommendSubjectList(page, pageSize, recommendStatus,SubjectName);
    }
    //批量修改首页推荐的状态
    public void updateRecommendSubjectStatus(List<Long> ids, Integer status) {
        recommendSubjectApi.updateRecommendSubjectStatus(ids,status);
    }
    //修改首页推荐
    public void updateRecommendSubjectSort(Long id, Integer sort) {
        HomeRecommendSubject RecommendSubject=new  HomeRecommendSubject();
        RecommendSubject.setId(id);
        RecommendSubject.setSort(sort);
        recommendSubjectApi.updateRecommendSubjectSort(RecommendSubject);
    }
}
